<script setup>
import Home_industry from '../components/Home_industry.vue'
import Home_personnel from '../components/Home_personnel.vue'
import Home_AgeDistribution from '../components/Home_AgeDistribution.vue'
import Home_employment from '../components/Home_employment.vue'
import Home_play from '../components/Home_play.vue'
import Home_region from '../components/Home_region.vue'
import Home_map from '../components/Home_map.vue'
import { ref } from 'vue'

const activeYear = ref('2024')
const years = ['2024', '2025']

const selectYear = (year) => {
  activeYear.value = year
}
</script>

<template>
  <div class="home-page">
    <div class="column">
      <div class="panel">
        <h2>柱形图-就业行业</h2>
        <Home_industry />
        <div class="panel-footer"></div>
      </div>
      <div class="panel">
        <h2>
          折线图-人员变化
          <a v-for="year in years" :key="year" :class="{ 'a-active': activeYear === year }" href="javascript:;"
            @click="selectYear(year)">
            {{ year }}
          </a>
        </h2>
        <!-- 传递 activeYear 给 Home_personnel -->
        <Home_personnel :year="activeYear" />
        <div class="panel-footer"></div>
      </div>
      <div class="panel">
        <h2>饼状图-年龄分布</h2>
        <Home_AgeDistribution />
        <div class="panel-footer"></div>
      </div>
    </div>
    <div class="column">
      <div class="no">
        <div class="no-hd">
          <ul>
            <li>12434</li>
            <li>10983</li>
          </ul>
        </div>
        <div class="no-bd">
          <ul>
            <li>前端需求人数</li>
            <li>市场供应人数</li>
          </ul>
        </div>
      </div>
      <div class="map">
        <div class="map1"></div>
        <div class="map2"></div>
        <div class="map3"></div>
        <div class="chart">
          <Home_map />
        </div>
      </div>
    </div>
    <div class="column">
      <div class="panel">
        <h2>柱状图-就业行业</h2>
        <Home_employment />
        <div class="panel-footer"></div>
      </div>
      <div class="panel">
        <h2>折线图-播放量</h2>
        <Home_play />
        <div class="panel-footer"></div>
      </div>
      <div class="panel">
        <h2>饼形图-地区分布</h2>
        <Home_region />
        <div class="panel-footer"></div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.home-page {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 10px 10px 0 10px;
  box-sizing: border-box;
  overflow: hidden;

  .column {
    flex: 3;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;

    .panel {
      position: relative;
      flex: 1;
      min-height: 0;
      padding: 0 15px;
      margin-bottom: 15px;
      border: 1px solid rgba(25, 186, 139, 0.17);
      background: url(../assets/line.png) rgba(255, 255, 255, 0.03);
      display: flex;
      flex-direction: column;

      h2 {
        height: 48px;
        color: #fff;
        line-height: 48px;
        text-align: center;
        font-size: 20px;
        font-weight: 400;

        a {
          color: #a7a7a7;
          text-decoration: none;
          margin: 0 10px;
        }
      }

      .a-active {
        color: #fff;
        text-decoration: none;
        margin: 0 10px;
      }

      .panel-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
      }

      /* 修改 ::before 伪元素的 content 属性值为双引号 */
      .panel-footer::before {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-left: 2px solid #02a6b5;
        border-bottom: 2px solid #02a6b5;
        content: "";
        /* 修改此处 */
      }

      /* 修改 ::after 伪元素的 content 属性值为双引号 */
      .panel-footer::after {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #02a6b5;
        border-bottom: 2px solid #02a6b5;
        content: "";
        /* 修改此处 */
      }

    }

    .panel::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 10px;
      height: 10px;
      border-left: 2px solid #02a6b5;
      border-top: 2px solid #02a6b5;
      content: "";
      /* 修改此处 */
    }

    .panel::after {
      position: absolute;
      top: 0;
      right: 0;
      width: 10px;
      height: 10px;
      border-right: 2px solid #02a6b5;
      border-top: 2px solid #02a6b5;
      content: "";
      /* 修改此处 */
    }
  }

  .column:nth-child(2) {
    flex: 5;
    margin: 0 10px 0px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .no {
    background-color: rgba(101, 132, 226, 0.1);
    padding: 15px;
    flex-shrink: 0;

    .no-hd {
      position: relative;

      border: 1px solid rgba(25, 186, 139, 0.17);

      ul {
        display: flex;

        li {
          position: relative;
          flex: 1;
          line-height: 80px;
          font-size: 70px;
          color: #ffeb7b;
          text-align: center;
          font-family: 'DS-Digit', sans-serif;
        }

        li:first-child::after {
          content: '';
          position: absolute;
          top: 25%;
          right: 0;
          height: 50%;
          width: 1px;
          background-color: rgba(255, 255, 255, 0.3);
        }
      }
    }

    .no-bd {
      ul {
        display: flex;

        li {
          flex: 1;
          text-align: center;
          color: rgba(255, 255, 255, 0.7);
          font-size: 18px;
          height: 40px;
          line-height: 40px;
          padding-top: 10px;
        }
      }
    }

    .no-hd::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 30px;
      height: 10px;
      border-top: 2px solid #02a6b5;
      border-left: 2px solid #02a6b5;
      content: '';
    }

    .no-hd::after {
      position: absolute;
      bottom: 0;
      right: 0;
      width: 30px;
      height: 10px;
      border-bottom: 2px solid #02a6b5;
      border-right: 2px solid #02a6b5;
      content: '';
    }
  }

  .map {
    position: relative;
    flex: 1;
    min-height: 0;

    .map1 {
      width: 518px;
      height: 518px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      opacity: 0.3;
      background: url(../assets/map.png) 0% 0% / 100% 100%;
    }

    .map2 {
      position: absolute;
      width: 643px;
      height: 643px;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      opacity: 0.6;
      background: url(../assets/lbx.png) 0% 0% / 100% 100%;
      animation: 15s linear 0s infinite normal none running rotate1;
    }

    .map3 {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 566px;
      height: 566px;
      background: url(../assets/jt.png) 0% 0% / 100% 100%;
      animation: 15s linear 0s infinite normal none running rotate2;
    }

    .chart {
      position: absolute;
      top: 0px;
      left: 0px;
      height: 100%;
      width: 100%;
    }
  }
}

/* 添加 rotate1 动画关键帧 */
@keyframes rotate1 {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes rotate2 {
  from {
    transform: translate(-50%, -50%) rotate(360deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(0deg);
  }
}

/* 响应式适配 */
/* 大屏幕 (1200px 及以上) */
@media (min-width: 1200px) {
  .home-page {
    padding: 15px 15px 0 15px;

    .column {
      .panel {
        height: 310px;
        padding: 0 20px 10px;

        h2 {
          font-size: 1.4rem;
          height: 52px;
          line-height: 52px;
        }
      }
    }

    .column:nth-child(2) {
      margin: 0 15px 20px;
    }
  }
}



/* 中等屏幕 (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .home-page {
    padding: 8px 8px 0 8px;

    .column {
      .panel {
        height: 280px;
        padding: 0 12px 35px;
        margin-bottom: 12px;

        h2 {
          font-size: 1.1rem;
          height: 44px;
          line-height: 44px;
        }
      }
    }

    .column:nth-child(2) {
      margin: 0 8px 12px;
    }
  }
}

/* 小屏幕 (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .home-page {
    flex-direction: column;
    /* 改为垂直布局 */
    padding: 5px 5px 0 5px;

    .column {
      flex: none;
      width: 100%;

      .panel {
        height: 250px;
        padding: 0 10px 30px;
        margin-bottom: 10px;

        h2 {
          font-size: 1rem;
          height: 40px;
          line-height: 40px;
        }
      }
    }

    .column:nth-child(2) {
      margin: 0 0 10px 0;
    }
  }
}

/* 超小屏幕 (575px 及以下) */
@media (max-width: 575px) {
  .home-page {
    flex-direction: column;
    padding: 5px 5px 0 5px;

    .column {
      flex: none;
      width: 100%;

      .panel {
        height: 220px;
        padding: 0 8px 25px;
        margin-bottom: 8px;

        h2 {
          font-size: 0.9rem;
          height: 36px;
          line-height: 36px;
        }

        /* 调整装饰边框大小 */
        &::before,
        &::after {
          width: 8px;
          height: 8px;
        }

        .panel-footer::before,
        .panel-footer::after {
          width: 8px;
          height: 8px;
        }
      }
    }

    .column:nth-child(2) {
      margin: 0 0 8px 0;
    }
  }
}
</style>